﻿using B.S.GridManager.Api.Read.Application.Command.LogicalGrid;
using B.S.GridManager.Api.Read.Dtos;
using B.S.GridManager.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManager.Api.Read.Controllers
{
    /// <summary>
    /// 逻辑网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogicalController : ControllerBase
    {
        private readonly IMediator mediator;

        public LogicalController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 查询逻辑网格接口
        /// </summary>
        /// <param name="request">请求参数</param>
        /// <returns>相应保证类的对象</returns>
        [HttpGet]
        public Task<ApiResult<List<LogialGridDTO>>> GetLogicGrid([FromQuery]GetLogicGridCommand request) { 
            return mediator.Send(request);
        }

        [HttpGet]
        public Task<ApiResult<List<LogicalGridTreeDTO>>> GetLogicalGridTree([FromQuery]GetLogicalGridTreeCommand request) {
            return mediator.Send(request);
        }
    }
}
